#include <iostream>
#include <string>
#include <cstring>

using namespace std;

const int N = 1e6 + 10;

int P[N], Q[N];

void push(int q[], int x)
{
	int& top = q[N - 1];
	q[top++] = x;
}

int pop(int q[])
{
	int& top = q[N - 1];
	return q[--top];
}

bool empty(int q[])
{
	return q[N - 1] == 0;
}

int query(int q[])
{
	int top = q[N - 1];
	return q[top - 1];
}

void RPN(string s)
{
	int tmp = 0;
	auto it = s.begin();
	char oper;

	while (it != s.end())
	{
		if (*it >= '0' && *it <= '9')
		{
			tmp = *it++ - '0';
			while (it != s.end() && *it >= '0' && *it <= '9')
			{
				tmp *= 10;
				tmp += *it++ - '0';
			}
			push(Q, tmp);
			tmp = 0;
		}
		else if (*it == '(')
			push(P, (*it++));
		else if (*it == ')')
		{
			oper = pop(P);
			while (oper != '(')
			{
				push(Q, oper * -1);
				oper = pop(P);
			}
			it++;
		}
		else if (*it == '/' || *it == '*')
		{
			if (!empty(P))
			{
				oper = query(P);
				while (oper == '/' || oper == '*')
				{
					oper = pop(P);
					push(Q, oper * -1);
					if (empty(P))
						break;
					oper = query(P);
				}
			}
			push(P, *it++);
		}
		else if (*it == '+' || *it == '-')
		{
			if (!empty(P))
			{
				oper = query(P);
				while (oper != '(')
				{
					oper = pop(P);
					push(Q, oper * -1);
					if (empty(P))
						break;
					oper = query(P);
				}
			}
			push(P, *it++);
		}
	}

	if (empty(P))
		return;
	oper = pop(P);
	while (1)
	{
		push(Q, oper * -1);
		if (empty(P))
			break;
		oper = pop(P);
	}
}

int sum[N];

int Calc(void)
{
	int a, b, s;

	for (int i = 0; i < Q[N - 1]; i++)
	{
		if (Q[i] >= 0)
			push(sum, Q[i]);
		else
		{
			a = pop(sum);
			b = pop(sum);

			switch (Q[i])
			{
			case -1 * '+':
				s = b + a;
				break;
			case -1 * '-':
				s = b - a;
				break;
			case -1 * '/':
				s = b / a;
				break;
			case -1 * '*':
				s = b * a;
				break;
			}
			push(sum, s);
		}
	}
	Q[N - 1] = 0;
	return pop(sum);
}

int main(void)
{
	string s;
	cin >> s;
	RPN(s);
	cout << Calc() << endl;
	return 0;
}